{template header}
<script type="text/javascript" src="{SITE_URL}public/js/jquery.upload.v2.js"></script>
<style>
    .timeline-body img {
        width: 100%;
        height: auto;
    }
</style>
<div class="container">

    <div class="row">
        <div class="col-md-8">
                        <div class="panel panel-default">
                            <div class="panel-body">
                                <ul class="nav nav-tabs" role="tablist">
                                    <li>
                                        <select onChange="MM_jumpMenu('parent',this,0)" style="font-size:10px;font-weight: 300;height: 20px">
                                            <!--{for $i=date('Y');$i>=2017;$i--}-->
                                            <option value="{tsUrl('history','index',array('year'=>$i,'cateid'=>$cateid))}" {if $year==$i}selected{/if}>{$i}年</option>
                                            <!--{/for}-->
                                         </select>
                                        <select onChange="MM_jumpMenu('parent',this,0)" style="font-size:10px;font-weight: 300;height: 20px">
                                            <option value="{tsUrl('history','index',array('year'=>$year))}"></option>
                                            {loop $arrCate $key $item}
                                            <option value="{tsUrl('history','index',array('year'=>$year,'cateid'=>$item['cateid']))}" {if $cateid==$item['cateid']}selected{/if}>{$item['catename']}</option>
                                            {/loop}
                                        </select>
                                        &nbsp;时间轴</li>
                                    {if $GLOBALS['TS_USER']['isadmin']== 1 }
                                    <li style="float: right" ><a onclick="showaddform()">添加</a></li>
                                    {/if}
                                    <li style="float: right">
                                </li>

                                </ul>
                                <div id="add_form" style="display: none">
                                    <br/>
                                    <form  id="record" class="form-horizontal" method="post" action="{SITE_URL}index.php?app=history&ac=add">
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">重要程度</label>
                                            <div class="col-sm-9">
                                                <select  name="grade" id="grade" class="form-control">
                                                    <option value="1">普通</option>
                                                    <option value="2">重要</option>
                                                    <option value="3">重大</option>
                                                </select>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">类别</label>
                                            <div class="col-sm-9">
                                                <select  name="cateid" id="cateid" class="form-control">
                                                    <option></option>
                                                    {loop $arrCate $key $item}
                                                    <option value="{$item['cateid']}" >{$item['catename']}</option>
                                                    {/loop}
                                                </select>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">日期</label>
                                            <div class="col-sm-3">
                                                <input class="form-control" name="begindate" readonly value="" id="begindate" />
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">标题</label>
                                            <div class="col-sm-9">
                                                <input type="text" class="form-control" name="title" id="title" placeholder="">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">详情</label>
                                            <div class="col-sm-9" >
                                                <div id="tseditor"></div>
                                                <div style="display: none">
                                                    <textarea name="content" class="form-control" style="width: 100%"  rows="5" placeholder=""></textarea>
                                                </div>

                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <div class="col-sm-offset-2 col-sm-10">
                                                <button data-id="submit" type="submit" class="btn btn-success">点击提交</button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                                {if $arrHistory}
                                <div class="weilist" id="weilist">
                                    <div class="timeline timeline-single-column" style="padding-top: 50px">
                                        <!--{for $i=12;$i>=1;$i--}-->
                                        {if $arrHistory[$i]}
                                        {loop $arrHistory[$i] $key $item}
                                        <div class="timeline-item">
                                            {if $item['grade']==3}
                                                <div class="timeline-point timeline-point-success">
                                                    <i class="fa fa-star"></i>
                                                </div>
                                            {else}
                                            {if $item['grade']==2}
                                                <div class="timeline-point timeline-point-success">
                                                </div>
                                            {else}
                                                <div class="timeline-point timeline-point-default">
                                                </div>
                                            {/if}
                                            {/if}


                                            <div class="timeline-event">
                                                <div class="panel-heading">
                                                    <h3 class="panel-title">$item['title']{if $GLOBALS['TS_USER']['isadmin']=='1'}<a  href="{tsUrl('history','deletehistory',array('historyid'=>$item[historyid]))}" style="float: right"><i class="fa fa-trash-o" aria-hidden="true"></i></a>{/if}</h3>
                                                </div>
                                                <div class="timeline-body">
                                                    <p>$item['content']</p>
                                                </div>
                                                <div class="timeline-footer primary">
                                                    <p class="text-right">{php echo date('Y-m-d',$item['begindate'])}</p>
                                                </div>
                                            </div>
                                        </div>
                                        {/loop}

                                        <span class="timeline-label">
                                            <span class="label label-info">{$year}-{$i}</span>
                                        </span>

                                        {/if}
                                        <!--{/for}-->
                                    </div>
                                 </div>
                                {/if}
                            </div>
                        </div>
                    </div>
                </div>
            </div>

<script>
    //隐藏列表，显示登记表单
    function showaddform(){
        $('#add_form').toggle();
    }
    $('#begindate').datetimepicker({
        language:  'zh-CN',
        format: 'yyyy-mm-dd',
        autoclose: true,
        minView:2
    });
    $(function(){
        $('#record').on('submit', function(e) {
            var grade  = $('#grade').val();
            var cateid  = $('#cateid').val();
            var begindate  = $('#begindate').val();
            var title  = $('#title').val();
            var content  = $('content').val();

            if (cateid == '') {
                bootbox.alert('类别不能为空');
                return false;
            }


            if (begindate == '') {
                bootbox.alert('日期不能为空');
                return false;
            }

            if (title == '') {
                bootbox.alert('标题不能为空');
                return false;
            }

            if (content == '') {
                bootbox.alert('详情必须填写');
                return false;
            }

            $('#add_form').modal('hide');
            location.reload();
        });
    });
    //删除服务记录
    function del(historyid){


        if (confirm('删除这条记录吗？')) {

            $.ajax({
                type: "POST",
                url: siteUrl+"index.php?app=history&ac=deletehistory",
                data: "historyid="+historyid,
                beforeSend:function(){
                },
                success:function(result){
                    if(result == '1'){
                        window.location.reload();
                    }
                }
            });

        }
    }

</script>
{php doAction('tseditor','m')}
{template footer}